<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Page Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
</head>
<body>
    a
    <iframe src="http://b.fullstackjavascript.cn:4000/b.html" frameborder="0" id="frame" onload="load()"></iframe>
    <script>
    /* 
    domain方式跨域要先保证两个页面属于同一个域下的 
    在hosts文件增加两个映射关系,位置在 C:\Windows\System32\drivers\etc
    127.0.0.1 a.fullstackjavascript.cn
    127.0.0.1 b.fullstackjavascript.cn
    */
        
    function load() {
        let frame=document.getElementById('frame');
        document.domain = 'fullstackjavascript.cn';
        console.log(frame.contentWindow.name);
    }
    </script>
</body>
</html>